/* This class serves as a template for one type of ship.
 * When information is read from the ship files, these templates will be built
 * 
 */

package item.ship;

import java.util.ArrayList;

import item.ItemPool;
import item.ItemTemplate;
import item.Rarity;
import item.weapon.Weapon;
import item.defense.Defense;
import item.engine.Engine;
import item.mod.Mod;


public class ShipTemplate extends ItemTemplate {


	private final int mHull; //the maximum hull
	private final int mArmor; //the maximum armor
	private final int mShields; //the maximum shields
	private final int maxNumWeapons; //the maximum number of weapons
	private final int maxNumDefenseItems; //the maximum number of defense items
	private final int maxNumEngines; //the maximum number of engines
	private final int maxNumMods; //the maximum number of mods
	private final ArrayList<String> weapons; //the list of weapons on the ship
	private final ArrayList<String> defenseItems; //the list of defense items
	private final ArrayList<String> engines; //the list of engines
	private final ArrayList<String> mods; //the list of modifications
	private final ShipClass shipClass; //the class of the ship
	private final ArrayList<String> shipAttributes; //used to mark the ship
	//with certain attributes used for determining if the ship can equip 
	//certain items


	//the main constructor that makes the template for every ship
	public ShipTemplate(String n, int minl, int maxl, int bc, int lc, int bw,
			int lw, String sP, Rarity r, int h,	int a, int s, int mw, int md,
			int me, int mm, ArrayList<String> wep, ArrayList<String> def,
			ArrayList<String> eng, ArrayList<String> mod, ShipClass sC,
			ArrayList<String> sT){

		super(n, minl, maxl, bc, lc, bw, lw, sP, r);

		mHull = h;
		mArmor = a;
		mShields = s;
		maxNumWeapons = mw;
		maxNumDefenseItems = md;
		maxNumEngines = me;
		maxNumMods = mm;
		weapons = new ArrayList<String>();
		defenseItems = new ArrayList<String>();
		engines = new ArrayList<String>();
		mods = new ArrayList<String>();
		shipClass = sC;		
		shipAttributes = new ArrayList<String>();

		for(String at: sT)
			shipAttributes.add(at);		

		for(String w: wep)
			this.equipW(w);

		for(String d: def)
			this.equipD(d);

		for(String e: eng)
			this.equipE(e);

		for(String m: mod)
			this.equipM(m);
	}//22 param constructor


	//returns the ship's attributes
	public ArrayList<String> getShipAttributes() {

		return shipAttributes;
	}//getShipAttributes


	//returns the class of the ship
	public ShipClass getShipClass() {

		return shipClass;
	}//getShipClass


	//equips the weapon if possible
	public boolean equipW(String w){

		if(true){

			weapons.add(w);
			return true;
		}//if

		return false;
	}//equip (Weapon)


	//equips the defensive item if possible
	public boolean equipD(String d){

		if(this.canEquip(new Defense())){

			defenseItems.add(d);
			return true;
		}//if

		return false;
	}//equip (Defense)


	//equips the modification if possible
	public boolean equipM(String m){

		if(this.canEquip(new Mod())){

			mods.add(m);
			return true;
		}//if

		return false;
	}//equip (Mod)


	//equips the engine if possible
	public boolean equipE(String e){

		if(this.canEquip(new Engine())){

			engines.add(e);
			return true;
		}//if

		return false;
	}//equip (Engine)


	//returns a generated ship using this template
	public Ship generate(int l){

		return null;
	}//generate	


	//returns if the ship can equip the weapon
	private boolean canEquip(Weapon w){

		return true;
	}//canEquip (Weapon)


	//returns if the ship can equip the defensive item
	private boolean canEquip(Defense d){

		return true;
	}//canEquip (Defense)


	//returns if the ship can equip the engine
	private boolean canEquip(Engine e){

		return true;
	}//canEquip (Engine)


	//returns if the ship can equip the mod
	private boolean canEquip(Mod m){

		return true;
	}//canEquip (Mod)
}//Ship